$(function()
{
	dislikesBG.safari = true;
	
	dislikesBG.jQuery = jQuery;
	
	dislikesBG.loadTranslations();
	
	dislikesBG.checkStatus();
	dislikesBG.sessionChkTimeout = setInterval('dislikesBG.checkStatus()', 30000);
});

safari.application.addEventListener("message", dislikesBG.onRequest, false);


dislikesBG.getBGurl = function(file)
{
	return safari.extension.baseURI + 'skin/' +file;
};

dislikesBG.HTMLParser = function(str)
{
	return str;
};

dislikesBG.loadOptions = function(callback, userID, doc)
{
	try 
	{			
		var lang = localStorage.getItem(userID+'_lang');
		if(lang == undefined || lang == null) throw {}
		
		dislikesBG.options.language = lang;
	} catch(e)	{}
	
	try 
	{			
		var firstTime = localStorage.getItem(userID+'_firstTime');
		if(firstTime == undefined || firstTime == null) throw {}
		
		dislikesBG.options.firstTime = firstTime;
	} catch(e)	{}
	
	try 
	{	
		var commentStuff = localStorage.getItem(userID+'_commentStuff');
		if(commentStuff == undefined || commentStuff == null) throw {}
		
		dislikesBG.options.commentStuff = commentStuff;
	} catch(e)	{}
	
	try 
	{			
		var postInfoToWall = localStorage.getItem(userID+'_postInfoToWall');
		if(postInfoToWall == undefined || postInfoToWall == null) throw {}
		
		dislikesBG.options.postInfoToWall = postInfoToWall;
	} catch(e)	{}
	
	var sendOpt = dislikesBG.jQuery.extend({}, dislikesBG.options, {trans: dislikesBG.transObj, friends: dislikesBG.friendsData});
	callback(sendOpt, doc);
};

dislikesBG.saveOptions = function(callback, userID, newOptions, doc)
{
	dislikesBG.options = dislikesBG.jQuery.extend({}, newOptions);
	
	try 
	{			
		localStorage.setItem(userID+'_lang', dislikesBG.options.language);
	} catch(e)	{}
	
	try 
	{			
		localStorage.setItem(userID+'_firstTime', dislikesBG.options.firstTime);
	} catch(e)	{}
	
	try 
	{			
		localStorage.setItem(userID+'_commentStuff', dislikesBG.options.commentStuff);
	} catch(e)	{}
	
	try 
	{			
		localStorage.setItem(userID+'_postInfoToWall', dislikesBG.options.postInfoToWall);
	} catch(e)	{}
	
	callback();
};